package com.duoduo.common.api.myinterface.delay;


import com.duoduo.common.api.domain.DelayExecuteMessage;
import com.duoduo.common.api.exception.delay.DelaySendException;
import com.duoduo.common.api.myinterface.mq.MessageHandler;
import com.duoduo.common.api.spi.extension.SPI;

import java.io.Serializable;

/**分布式延迟任务
 * @author duoduo
 *
 */
@SPI
public interface DelayManage {
	
	/**放入任务
	 * @param message
	 * @param delayTime 指定多少秒后执行
	 * @throws DelaySendException 发送延迟任务异常
	 */
	<T extends Serializable> void sendDelayMessage(DelayExecuteMessage<T> message, int delayTime) throws DelaySendException;
	
	/**初始化任务消费者信息
	 * @param dealKey
	 * @param minThreadNum
	 * @param maxThreadNum
	 * @param queueCapacity
	 * @param threadName 线程名
	 * @param handler
	 */
	void init(String dealKey, int minThreadNum, int maxThreadNum, int queueCapacity, String threadName, MessageHandler handler) throws Exception;

}
